import React, { Component } from 'react'
import Item from './Item'
import PropTyoe from 'prop-types'
export default class List extends Component {

  //对接收的props进行：类型、必要性的限制
  static propTypes = {
    todos: PropTyoe.array.isRequired,
    updateTodo: PropTyoe.func.isRequired,
    deleteTodo: PropTyoe.func.isRequired
  }

  render() {
    const props = this.props
    return (
      <ul className="todo-main">
        {
          props.todos.map(todo => {
            return <Item key={todo.id} {...todo} updateTodo={props.updateTodo} deleteTodo={props.deleteTodo} />
          })
        }

      </ul>
    )
  }
}
